import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:yqys_target/gen/assets.gen.dart';
import 'package:yqys_target/pages/raise_detail_page.dart';

import '../widgets/yq_list_card.dart';

class MoreWelfarePage extends StatelessWidget {
  const MoreWelfarePage({super.key});

  @override
  Widget build(BuildContext context) {
    return AnnotatedRegion(
      value: const SystemUiOverlayStyle(
        statusBarColor: Colors.transparent,
        statusBarIconBrightness: Brightness.dark,
        statusBarBrightness: Brightness.dark,
      ),
      child: Scaffold(
        appBar: AppBar(
          title: const Text(
            '更多益事',
            style: TextStyle(
              fontSize: 18,
              fontWeight: FontWeight.bold,
              color: Colors.black,
            ),
          ),
          backgroundColor: Colors.white,
          elevation: 0,
          centerTitle: true,
          leading: IconButton(
            icon: const Icon(
              Icons.arrow_back_ios,
              color: Colors.black,
            ),
            onPressed: () => Navigator.of(context).pop(),
          ),
        ),
        body: ListView.builder(
          padding: const EdgeInsets.all(16),
          itemCount: 4, // 根据实际数据长度调整
          itemBuilder: (context, index) {
            // 这里使用示例数据，实际应该从数据源获取
            final List<Map<String, dynamic>> items = [
              {
                'title': '乡村留守儿童免费午餐',
                'progress': 0.869,
                'progressText': '86.9%',
                'target': '1亿'
              },
              {
                'title': '捐爱心蛋，助力乡村老人好好吃饭',
                'progress': 0.948,
                'progressText': '94.8%',
                'target': '1亿'
              },
              {
                'title': '园梦儿童自然素养课',
                'progress': 0.465,
                'progressText': '46.5%',
                'target': '1亿'
              },
              {
                'title': '助力喂食流浪的小动物',
                'progress': 0.206,
                'progressText': '20.6%',
                'target': '1亿'
              },
            ];

            final item = items[index];

            return PublicWelfareCard(
              imageUrl: Assets.images.project1.path,
              title: item['title'],
              progress: item['progress'],
              progressText: item['progressText'],
              target: item['target'],
              onTap: () {
                // 处理项目点击
                Navigator.of(context).push(
                  MaterialPageRoute(
                    builder: (context) => RaiseDetailPage(
                      progress: index % 2 == 0 ? 0.869 : 0.552,
                      progressText: index % 2 == 0 ? '86.9%' : '55.2%',
                      target: '1亿',
                      title: index % 2 == 0 ? '乡村留守儿童免费午餐' : '捐爱心蛋，助力乡村老人好好吃饭',
                      description: '让清江河大龙潭至旗峰坝路段所有的小孩子都可以自由的欢笑我们还可以更美好',
                    ),
                  ),
                );
              },
            );
          },
        ),
      ),
    );
  }
}
